package cn.me.alphamq.broker.rebalance;

import java.util.ArrayList;
import java.util.List;

/**
 * 消费者的实例
 *
 * @author f
 */
public class ConsumerInstance {

    /**
     * 消费者的 ip 地址
     */
    private String consumerIp;

    /**
     * 消费者的 端口号
     */
    private Integer consumerPort;

    /**
     * 消费者消费的主题
     */
    private String topic;

    /**
     * 消费者组
     */
    private String consumerGroup;

    /**
     * 消费队列的 id
     */
    private Integer queueId;

    /**
     * 消费者消费的队列 id 集合，由算法动态分配
     */
    private List<Integer> queueIdList;

    public ConsumerInstance() {
    }

    public ConsumerInstance(String consumerIp, Integer consumerPort,
                            String topic, String consumerGroup, Integer queueId) {
        this.consumerIp = consumerIp;
        this.consumerPort = consumerPort;
        this.topic = topic;
        this.consumerGroup = consumerGroup;
        this.queueId = queueId;
    }

    public String getConsumerIp() {
        return consumerIp;
    }

    public Integer getConsumerPort() {
        return consumerPort;
    }

    public String getTopic() {
        return topic;
    }

    public String getConsumerGroup() {
        return consumerGroup;
    }

    public List<Integer> getQueueIdList() {
        return queueIdList;
    }

    public Integer getQueueId() {
        return queueId;
    }

    public void setQueueId(Integer queueId) {
        this.queueId = queueId;
    }

    /**
     * 恢复 queueIdList 的空集合
     */
    public void restoreQueueIdList() {
        queueIdList = new ArrayList<>();
    }
}
